import React, { Fragment, PureComponent } from 'react'
import { connect } from 'dva'
import { OssUpload } from 'scd'
import { Col, Checkbox, Form, Input, Spin, Icon, Select, Button } from 'antd'
const FormItem = Form.Item;
const Option = Select.Option

@connect(({ loading, dispatch, app, role }) => ({
  app,
  role,
  // loading: loading.effects['app/searchOrganizTree'],
}))
@Form.create()

class SearchForm extends PureComponent {
  state = {
    selectedItems: [],
  }
  search = () => {//搜索
    const { dispatch, searchProps, form: { validateFieldsAndScroll }, app: { singleOriginal } } = this.props
    validateFieldsAndScroll((err, values) => {
      if (err) return
      dispatch({
        type: 'role/getRoleList',
        payload: {
          orgId: singleOriginal.id,
          ...searchProps,
          ...values
        }
      })
    })
  }

  reset = () => {
    const { dispatch, searchProps, app: { singleOriginal }, form: { resetFields }, } = this.props
    resetFields()
    dispatch({
      type: 'role/getRoleList',
      payload: {
        orgId: singleOriginal.id,
        ...searchProps
      }
    })
  }

  handleChange = selectedItems => {
    this.setState({ selectedItems });
  };



  render() {
    const { selectedItems } = this.state
    const { form: { getFieldDecorator }, app: { singleOriginal, imgUrlList } } = this.props
    const optionList = ['Apples', 'Nails', 'Bananas', 'Helicopters'];
    const filteredOptions = optionList.filter(o => !selectedItems.includes(o));
    return (
      <React.Fragment>
        <Form layout="inline" style={{ margin: "20px 0" }}>
          <FormItem label="产品线" >
            {getFieldDecorator('resBizName')
              (<Select placeholder="请选择" style={{ width: '200px' }}>
                <Option key="0" value="0">公共服务平台</Option>
                <Option key="1" value="1">发票协同</Option>
                <Option key="2" value="2">合同履约</Option>
                <Option key="3" value="3">供应链金融</Option>
                <Option key="4" value="4">税务信息</Option>
              </Select>)}
          </FormItem>
          <FormItem label="角色类型" >
            {getFieldDecorator('authType')
              (<Select placeholder="请选择" style={{ width: '200px' }}>
                <Option key="0" value="0">管理类型</Option>
                <Option key="1" value="1">业务类型</Option>
              </Select>)}
          </FormItem>
          <FormItem>
            <Button type="primary" onClick={this.search}>查询</Button>
            <Button onClick={this.reset} style={{ marginLeft: '8px' }}>重置</Button>
          </FormItem>
        </Form>
      </React.Fragment>
    );
  }
}

export default SearchForm;









